<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>客户开票清单汇总打印</title>
    <script src="/jquery-1.8.3.min.js"></script>
    <script src="/printThis.js"></script>
    <script src="/chineseMoney.js"></script>
    <script src="/tools.js"></script>
    <link rel="stylesheet" href="/print.css"/>
</head>
<body>
<div id="receiptPrintArea0">
    <h3 style="text-align: center">客户开票清单汇总</h3>
    <br/>
    <table width="100%">
        <tr>
            <td width="25%">配送日期范围：</td><td width="75%"><span class="supplyDate"></span></td>
        </tr>
        <tr>
            <td width="25%">客户名称：</td><td width="75%"><span class="customer"></span></td>
        </tr>
        <tr>
            <td width="25%">餐别：</td><td width="75%"><span class="mealsType"></span></td>
        </tr>
        <tr>
            <td width="25%">食材类型：</td><td width="75%"><span class="foodType"></span></td>
        </tr>
        <tr>
            <td width="25%">合计金额：</td><td width="75%"><span class="total"></span>&nbsp;
            大写：<span class="chineseMoney"></span></td>
        </tr>
    </table>
    <br/>
    <table style="width: 100%;" class="printTable">
        <thead style="border: 1px solid">
        <td width="8%">序号</td>
        <td width="20%">名称</td>
        <td width="4%"> </td>
        <td width="13%">规格</td>
        <td width="13%">品牌</td>
        <td width="8%">单位</td>
        <td width="8%">税率</td>
        <td width="13%">数量</td>
        <td width="13%">金额</td>
        </thead>
        <tbody id="content">
        </tbody>
    </table>
</div>
<script th:inline="javascript">
    var params = [[${params}]];
    var backAddress = params.backAddress;
    var beginSupplyDate = params.beginSupplyDate;
    var endSupplyDate = params.endSupplyDate;
    var customer = params.customerId;
    var customerName = params.customerName;
    var mealsTypeId = params.mealsTypeId;
    /*if (typeof(params.mealsTypeId) != 'object') {
        mealsTypeId = [];
        mealsTypeId.push(params.mealsTypeId) ;
    }  else mealsTypeId = params.mealsTypeId;*/
    var mealsTypeName = params.mealsTypeName;
    var foodMaterialTypeId = params.foodMaterialTypeId;
    var foodMaterialTypeName = params.foodMaterialTypeName;
    function print() {
        $("#receiptPrintArea0").printThis({
            debug: false,
            importCSS: true,
            importStyle: true,
            printContainer: true,
            pageTitle: "",
            removeInline: false,
            printDelay: 333,
            header: null,
            formValues: true
        });
    }
    $.ajax({
        url: backAddress + "/api/financial/queryBillingDetailedList",
        type: "post",
        dataType: "json",
        contentType: "application/json;charset=utf-8",
        data : JSON.stringify({
            "beginSupplyDate" : beginSupplyDate,
            "endSupplyDate" : endSupplyDate,
            "customerId" : customer,
            "mealsTypeId" : mealsTypeId,
            "foodMaterialTypeId" : foodMaterialTypeId,
            "pageNo" : 1,
            "pageSize" : 2000
        }),
        success: function (data) {
            //console.log(data)
            $(".supplyDate")[0].innerText = beginSupplyDate + '至' + endSupplyDate;
            $(".customer")[0].innerText = customerName;
            $(".mealsType")[0].innerText = mealsTypeName;
            $(".foodType")[0].innerText = foodMaterialTypeName;
            var str = '' ;
            var total = 0 ;
            for (var i = 0 ; i < data.data.list.length ; i++) {
                str = "<tr><td width=\"8%\">" + (i + 1) + "</td>" +
                    "<td width=\"20%\">" + data.data.list[i].foodMaterialName + "</td>" +
                    "<td width=\"4%\">" + getOriginalProcessShow(data.data.list[i].originalProcess) + "</td>" +
                    "<td width=\"13%\">" + dealNull(data.data.list[i].specs) + "</td>" +
                    "<td width=\"13%\">" + dealNull(data.data.list[i].brand) + "</td>" +
                    "<td width=\"8%\">" + dealNull(data.data.list[i].unitName) + "</td>" +
                    "<td width=\"8%\">" + data.data.list[i].raxRate + "</td>" +
                    "<td width=\"13%\">" + data.data.list[i].totalAmount + "</td>" +
                    "<td width=\"13%\">" + data.data.list[i].total + "</td></tr>" ;
                $("#content").append($(str));
                total += data.data.list[i].total * 100 ;
            }
            $(".total")[0].innerText = total / 100 ;
            $(".chineseMoney")[0].innerText = Arabia_to_Chinese((total/100) + '') ;
            print()
        },
        error: function (status) {
            alert(status)
        }
    })
</script>
</body>
</html>